import React, { Component } from 'react'
import { Text, StyleSheet, View ,Dimensions, Alert } from 'react-native'
import {Camera,useCameraDevice} from 'react-native-vision-camera';

 
function App() {
    const device = useCameraDevice('back');
    if (device == null) {
        return Alert.alert('No camera found');
    }
    return (
        <View style={styles.container}>
            <Camera
                style={styles.absoluteFill}
                device={device}//设置相机设备
                isActive={true}//设置是否激活相机
            />
        </View>
    );
}

const styles = StyleSheet.create({
    absoluteFill: {
        position: 'absolute',
        top: 0,
        width: Dimensions.get('window').width,
        height: Dimensions.get('window').height,
        backgroundColor: 'black',
    },
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center'
    }
})
   
 
export default App;